// 屏幕UI动态适配

// 编辑UI的屏幕分辨率，以此为基准。
const setupScale = {
    x: 1920,
    y: 858,
};

// 获取所有屏幕
const allScreen = UiScreen.getAllScreen();

function scaleScreen(sH: number, sW: number) {
    let scaleFactor: number = 1;
    if ((sW + sH) / 2 < (setupScale.x + setupScale.y) / 2.1) {
        scaleFactor = (sW + sH) / (setupScale.x + setupScale.y);
    }
    const uiScale = UiScale.create();
    uiScale.scale = scaleFactor;
    allScreen.forEach((e) => {
        e.uiScale = uiScale;
    });
    // console.log('screen:', sW, 'x', sH);
}

scaleScreen(screenWidth, screenHeight);

screen.events.add('resize', () => {
    const evt = navigator.getDeviceInfo();
    scaleScreen(evt.screen.height, evt.screen.width);
});
